﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="userLogin.aspx.cs" Inherits="WebSite.cn.userLogin" %>

  <%@ Register Src="head.ascx" TagName="head" TagPrefix="uc1" %>
<%@ Register Src="bottom.ascx" TagName="bottom" TagPrefix="uc3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title><%=WebSite.info.info1("", "shoptitle")%></title>
    <meta name="Description" content="<%=WebSite.info.info1("","shopcontent")%>" /> 
    <meta name="Keywords" content="<%=WebSite.info.info1("","shopkey")%>" />

     <link href="/cn/css/login_register.css" type="text/css" rel="stylesheet" />
</head>

<body class="login">
<form id="form1" runat="server">

<uc1:head ID="head_1" runat="server" />
<center>
  <div class="page_navigater">
			<p><a href="/cn/index.aspx">首页</a>>用户中心</p>
  </div>
  <div class="clear"></div>
<div class="login_register_con">
<div class="login">
    <h2><strong>全员登录</strong></h2>
<p><label for="txtUserName">用户名:</label><input id="txtLoginUserName" value="<% =GetMemberLoginName %>" type="text" /><span id="spLoginUserName">*</span></p>
<p><label for="txtUserPwd">用户密码:</label><input id="txtLoginUserPwd" type="password" /><span id="spLoginUserPwd">*</span></p>
<p><label for="txtCode">验证码:</label><input id="txtLoginCode" type="text" maxlength="5" class="txtCode" autocomplete="off" /><img id="imgLoginCheckCode" src="/admin/checkCode.aspx" alt="看不清楚,换一张" onclick="this.src = this.src + '?' + new Date().getTime();" class="imgCode" /><span id="spLoginCode">*</span></p>
<p>
<label>&nbsp;</label>
 
<a href="/cn/forget.aspx">忘记密码？</a></p>
<p>
<label>&nbsp;</label>
<input id="btnLogoinSubmit" class="submit" type="submit" value="" />


</p>
</div>

    <div class="register">
<h2><strong> 注册新会员</strong></h2>

<p><label for="txtUserName">用户名:</label><input id="txtUserName" type="text"  onpaste="return false" style="ime-mode: disabled" onkeydown="if(event.keyCode==13)event.keyCode=9"/><span id="spUserName">*4～16个字符,包括数字、英文字母、下划线</span></p>
<p><label for="txtUserPwd">用户密码:</label><input id="txtUserPwd" type="password" /><span id="spPwd">*6～16个字符,包括数字、英文字母、任意字符</span></p>
<p><label for="txtAgainPwd">确认密码:</label><input id="txtAgainPwd" type="password" /><span id="spAgPwd">*</span></p>
<p><label for="txtEmail">电子邮箱:</label><input id="txtEmail" type="text" /><span id="spEmail">*</span></p>
<p><label for="txtCode">验证码:</label><input id="txtCode" type="text" maxlength="5" class="txtCode" autocomplete="off" /><img id="imgCheckCode" src="/admin/checkCode.aspx"  alt="看不清楚,换一张" onclick="this.src = this.src + '?' + new Date().getTime();" class="imgCode" /><span id="spCode">*</span></p>
<p>
<label>&nbsp;</label>
<input id="cbServer" type="checkbox" class="check_box" value="同意" />&nbsp;已阅读并同意<a href="/cn/registerAgre.htm?TB_iframe=true&height=500&width=800" title="服务条款" class="thickbox">《商城服务条款》</a>
</p>
<p>
<label>&nbsp;</label>
<input id="btnRegisterSubmit" class="register_submit" type="submit" value="" /></p>

</div>
</div>
 <uc3:bottom ID="bottom_1" runat="server" />
 </center>
   </form>
</body>
</html>

<script language="javascript" type="text/javascript">

    $(function () {
        $("#txtLoginUserName").blur(function () {
            if ($("#txtLoginUserName").val() == "") {
                $("#spLoginUserName").html("<img src=\"/cn/images/wrong.gif\" />");
            } else {
                $("#spLoginUserName").html("<img src=\"/cn/images/right.gif\" />");
            }

            return false;
        });
        $("#txtLoginUserPwd").blur(function () {
            if ($("#txtLoginUserPwd").val() == "") $("#spLoginUserPwd").html("<img src=\"/cn/images/wrong.gif\" /> ");
            else {
                $("#spLoginUserPwd").html("<img src=\"/cn/images/right.gif\" />");
            }
            return false;
        });

        $("#txtLoginCode").blur(function () {
            if ($("#txtLoginCode").val() == "") $("#spLoginCode").html("<img src=\"/cn/images/wrong.gif\" /> ");
            else $("#spLoginCode").html("<img src=\"/cn/images/right.gif\"/>");
            return false;
        });


        $("#btnLogoinSubmit").click(function () {


            ///用户名
            if ($("#txtLoginUserName").val() == "") {
                $("#txtLoginUserName").select();
                $("#spLoginUserName").html("<img src=\"/cn/images/wrong.gif\" /> 请输入用户名！");
                return false;
            }
            else $("#spLoginUserName").html("<img src=\"/cn/images/right.gif\"/>");
            ///用户密码
            if ($("#txtLoginUserPwd").val() == "") {
                $("#txtLoginUserPwd").select();
                $("#spLoginUserPwd").html("<img src=\"/cn/images/wrong.gif\" />请输入密码！");
                return false;
            } else $("#spLoginPwd").html("<img src=\"/cn/images/right.gif\"/>");
            ///验证码
            if ($("#txtLoginCode").val() == "") {
                $("#txtLoginCode").select();
                $("#spLoginCode").html("<img src=\"/cn/images/wrong.gif\" /> 请输入验证码！");
                return false;
            } else $("#spLoginCode").html("<img src=\"/cn/images/right.gif\"/>");



            $.ajax({
                type: "POST",
                url: "/loginHandler.ashx",
                data: "userName=" + escape($("#txtLoginUserName").val()) + "&userPwd=" + escape($("#txtLoginUserPwd").val()) + "&code=" + escape($("#txtLoginCode").val()) + "&action=login&lspname=1",
                success: function (msg) {

                    if (msg == "0") {
                        $("#txtLoginCode").select();
                        $("#spLoginCode").html("<img src=\"/cn/images/wrong.gif\" /> 验证码错误！");
                        $("#spLoginUserName").html("<img src=\"/cn/images/right.gif\"/>");
                        $("#imgLoginCheckCode").attr("src", "/admin/checkCode.aspx?id=" + parseInt(10000 * Math.random()));

                    }
                    else if (msg == "1") {
                        $("#txtLoginUserName").select();
                        $("#spLoginUserName").html("<img src=\"/cn/images/wrong.gif\" /> 用户名不存在！");
                        $("#spLoginCode").html("<img src=\"/cn/images/right.gif\"/>");

                    }
                    else if (msg == "2") {

                        $("#txtLoginUserPwd").select();
                        $("#spLoginUserPwd").html("<img src=\"/cn/images/wrong.gif\" /> 用户名或密码错误！");
                        $("#spLoginUserName").html("<img src=\"/cn/images/right.gif\"/>");
                        $("#spLoginCode").html("<img src=\"/cn/images/right.gif\"/>");

                    }
                    else if (msg == "3") {
                        $("#txtLoginUserName").select();
                        $("#spLoginUserName").html("<img src=\"/cn/images/wrong.gif\" /> 该用户被停用！");
                        $("#spLoginUserPwd").html("<img src=\"/cn/images/right.gif\"/>");
                        $("#spLoginCode").html("<img src=\"/cn/images/right.gif\"/>");

                    }
                    else if (msg == "4" || msg == "5" || msg == "6") {
                        art.dialog.tips("恭喜您，登录成功！", 1.5);
                        setTimeout("window.location.href='userInfo.aspx'", 2000);


                    }
                }
            });
            return false;
        });



        //---------------------

        $("#txtUserName").blur(function () {
            if ($("#txtUserName").val() == "") {
                $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 请输入用户名！");
            }
            else {
                if ($("#txtUserName").val().length < 4 || $("#txtUserName").val().length > 16)
                    $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 用户名长度不符！");
                else $("#spUserName").html("<img src=\"/cn/images/right.gif\"/>");
            }
            return false;
        });
        $("#txtUserPwd").blur(function () {
            if ($("#txtUserPwd").val() == "") $("#spPwd").html("<img src=\"/cn/images/wrong.gif\" /> 请输入密码！");
            else {
                if ($("#txtUserPwd").val().length < 6 || $("#txtUserPwd").val().length > 16)
                    $("#spPwd").html("<img src=\"/cn/images/wrong.gif\" /> 密码长度不符，必须在6-16个字符之间！");
                else $("#spPwd").html("<img src=\"/cn/images/right.gif\"/>");
            }
            return false;
        });

        $("#txtAgainPwd").blur(function () {
            if ($("#txtAgainPwd").val() == "") $("#spAgPwd").html("<img src=\"/cn/images/wrong.gif\" /> 请输入确认密码！");
            else {
                if ($("#txtAgainPwd").val() != $("#txtUserPwd").val())
                    $("#spAgPwd").html("<img src=\"/cn/images/wrong.gif\" /> 确认密码不一致！");
                else $("#spAgPwd").html("<img src=\"/cn/images/right.gif\"/>");
            }
            return false;
        });
        $("#txtEmail").blur(function () {
            if ($("#txtEmail").val() == "") $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 请输入电子邮箱！");
            else {
                if ($("#txtEmail").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null)
                    $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 电子邮箱格式不符！");
                else $("#spEmail").html("<img src=\"/cn/images/right.gif\"/>");
            }
            return false;
        });
        $("#txtCode").blur(function () {
            if ($("#txtCode").val() == "") $("#spCode").html("<img src=\"/cn/images/wrong.gif\" /> 请输入验证码！");
            else $("#spCode").html("<img src=\"/cn/images/right.gif\"/>");
            return false;
        });
        $("#cbServer").blur(function () {
            if (!$("#cbServer").attr("checked")) art.dialog.tips("请阅读并同意《商城服务条款》！", 1.5);
            return false;
        });

        $("#btnRegisterSubmit").click(function () {
            ///用户名
            if ($("#txtUserName").val() == "") {
                $("#txtUserName").select();
                $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 请输入用户名！");
                return false;
            }
            else {
                if ($("#txtUserName").val().length < 4 || $("#txtUserName").val().length > 16) {
                    $("#txtUserName").select();
                    $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 用户名长度不符！");
                    return false;
                } else $("#spUserName").html("<img src=\"/cn/images/right.gif\"/>");
            }
            ///用户密码
            if ($("#txtUserPwd").val() == "") {
                $("#txtUserPwd").select();
                $("#spPwd").html("<img src=\"/cn/images/wrong.gif\" /> 请输入密码！");
                return false;
            } else {
                if ($("#txtUserPwd").val().length < 6 || $("#txtUserPwd").val().length > 16) {
                    $("#txtUserPwd").select();
                    $("#spPwd").html("<img src=\"/cn/images/wrong.gif\" /> 密码长度不符，必须在6-16个字符之间！");
                    return false;
                } else $("#spPwd").html("<img src=\"/cn/images/right.gif\"/>");
            }
            ///确认密码
            if ($("#txtAgainPwd").val() == "") {
                $("#txtAgainPwd").select();
                $("#spAgPwd").html("<img src=\"/cn/images/wrong.gif\" /> 请输入确认密码！");
                return false;
            } else {
                if ($("#txtAgainPwd").val() != $("#txtUserPwd").val()) {
                    $("#txtAgainPwd").select();
                    $("#spAgPwd").html("<img src=\"/cn/images/wrong.gif\" /> 确认密码不一致！");
                    return false;
                } else $("#spAgPwd").html("<img src=\"/cn/images/right.gif\"/>");
            }
            ///Email
            if ($("#txtEmail").val() == "") {
                $("#txtEmail").select();
                $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 请输入电子邮箱！");
                return false;
            } else {
                if ($("#txtEmail").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null) {
                    $("#txtEmail").select();
                    $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 电子邮箱格式不符！");
                    return false;
                } else $("#spEmail").html("<img src=\"/cn/images/right.gif\"/>");
            }
            if ($("#txtCode").val() == "") {
                $("#txtCode").select();
                $("#spCode").html("<img src=\"/cn/images/wrong.gif\" /> 请输入验证码！");
                return false;
            } else $("#spCode").html("<img src=\"/cn/images/right.gif\"/>");
            if (!$("#cbServer").attr("checked")) {
                $("#cbServer").focus();
                art.dialog.tips("请阅读并同意《商城服务条款》！", 1.5);
                return false;
            }
            $.ajax({
                type: "POST",
                url: "/registerHandler.ashx",
                data: "userName=" + escape($("#txtUserName").val()) + "&userPwd=" + escape($("#txtUserPwd").val()) + "&email=" + escape($("#txtEmail").val()) + "&code=" + escape($("#txtCode").val()),
                success: function (msg) {
                    if (msg == "1002") {
                        $("#txtCode").select();
                        $("#spCode").html("<img src=\"/cn/images/wrong.gif\" /> 验证码错误！");
                        $("#spUserName").html("<img src=\"/cn/images/right.gif\"/>");
                        $("#imgCheckCode").attr("src", '/admin/checkCode.aspx?' + new Date().getTime());


                    }
                    else if (msg == "1003") {
                        $("#txtUserName").select();
                        $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 用户名已存在！");
                        $("#spCode").html("<img src=\"/cn/images/right.gif\"/>");

                    }
                    else if (msg == "1004") {
                        $("#txtEmail").select();
                        $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 电子邮箱已注册！");
                        $("#txtEmail").select();

                    }
                    else if (msg == "1001") {
                        $("#imgCheckCode").attr("src", '/admin/checkCode.aspx?' + new Date().getTime());
                        art.dialog.tips("很抱歉，注册失败！", 1.5);
                    }
                    else if (msg == "1005") {
                        art.dialog.tips("恭喜您，注册成功！", 3);
                        setTimeout("window.location.href='userInfo.aspx'", 2000);

                    }
                    else if (msg == "1006") {
                        art.dialog.tips("恭喜您，注册成功！", 3);
                        setTimeout("window.location.href='userInfo.aspx'", 2000);

                    }
                }
            });
            return false;
        });
        $("#btnAgreeServicet").click(function () {
            parent.$("#cbServer").attr("checked", "checked");
            parent.TB_remove();
        });
        $("#btnCancelServicet").click(function () {
            parent.TB_remove();
        });

    });

</script>

